<?php
/**
 * Created By PhpStorm.
 * User: RenJianHong
 * Date: 2021-08-03 14:32
 */

namespace Modules\Order\Entities;
use Modules\Order\Entities\OrderDetail;
use Modules\Order\Entities\Order;
use Illuminate\Support\Facades\DB;

class UserCapitalLog extends BaseModel
{
    protected $table = "user_capital_log";
    protected $guarded = [];
    
    /**
     * 插入积分记录
     */
    public static function saveLog($data)
    {
        $userCapitalLog = new UserCapitalLog();
        $userCapitalLog->user_id = $data['user_id'];
        $userCapitalLog->operate = $data['operate'];
        $userCapitalLog->type = $data['type'];
        $userCapitalLog->amount = $data['amount'];
        $userCapitalLog->description = $data['description'];
        !empty($data['admin_id']) && $userCapitalLog->admin_id = $data['admin_id'];
        !empty($data['operate_name']) && $userCapitalLog->operate_name = $data['operate_name'];

        if($userCapitalLog->save()){
            return true;
        }else{
            return false;
        }
    }
}